package com.jgp.config;

import com.jgp.common.utils.JGPUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;

/**
 * 项目   jgp-cloud-parent
 * 作者   loufei
 * 时间   2019/3/26
 */
@Order(300)
@Configuration
@ComponentScan(basePackages = {"com.**.component"}, basePackageClasses = {Component.class})
public class OtherComponentConfiguration {
    @Bean
    public MappingJackson2HttpMessageConverter jacksonMessageConverter() {
        MappingJackson2HttpMessageConverter converter5 = new MappingJackson2HttpMessageConverter();
        converter5.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8, MediaType.TEXT_PLAIN));
        converter5.setObjectMapper(JGPUtil.MAPPER);
        return converter5;
    }
    
    @Bean
    RestTemplate restTemplate() {
        RestTemplate restTemplate = new RestTemplate();
        restTemplate.getMessageConverters().add(jacksonMessageConverter());
        return restTemplate;
    }
}
